Ext.define('App.system.userList', {
    extend      : 'Ext.panel.Panel',
    alias       : 'widget.userListPanel',
    layout:'fit',
    autoScroll:true,
    autoHeight:true,
    initComponent : function() {
    	var grid,  selModel,  searchFlds;
    		searchFlds = new Ext.util.MixedCollection();
    		var fldTimeName = new Ext.form.TextField({
    			name : 'loginName',
    			fieldLabel : '用户名',
    			allowBlank : true,
    			width : 200
    		});
    		searchFlds.add('loginName', fldTimeName);
        var	toolbar = new Ext.Toolbar({
            enableOverflow : true,
            items : [ {
                text : "新增",
                iconCls : 'addIcon',
                handler : function() {
                	 var  codeForm = Ext.create('App.system.userForm');
                     codeForm.show();
                     codeForm.setTitle('新增');
                }
            }, '-', {
                text : "编辑",
                iconCls : 'editIcon',
                handler : function() {
                     var sm = Ext.getCmp('userGrid').getSelectionModel();
                     var records = sm.getSelection();
                     if (records.length <= 0) {
                         Ext.Msg.alert('错误', "未选中记录，不能修改！");
                         return;
                     }
                    var  userForm = Ext.create('App.system.userForm');
                    userForm.show();
                    userForm.setTitle('编辑');
                     var data = records[0].data;
                     userForm.down('form').getForm().loadRecord(records[0]);
                    userForm.down('form').getForm().findField('rolesName').setValue(data.rolesName);
                }
            }, '-', {
                text : "删除",
                iconCls : 'deleteIcon',
                handler : function() {
                	  Ext.getCmp('userGrid').deleteRecord();
                }
            }, '-', {
                text : "重置密码",
                handler : function() {
                    InitPassword();
                }
            },'-', {
                text : "启用/禁用",
               
                handler : function() {
                    Enable();
                }
            }, "->",  searchFlds.get("loginName"), {
                text: "搜索",
                iconCls : 'searchIcon',
                handler: function () {
                	 Ext.getCmp('userGrid').load();
                }
            } ]
        });
    		grid =	Ext.create('gridView',{
    			remoteSort : true,
                gridId :  'userGrid',
    			checkboxSelectionModel:true,
                autoscroll: true,
                searchFlds : searchFlds,
    			entityClassName : 'com.rover.system.entity.User',
    			queryUrl : 'userController/query.action',
    			deleteUrl : 'userController/delete.action',
                tbar:toolbar,
    			recordPk : [ "id" ]
    		});
    		selModel = grid.getSelectionModel();
    		selModel.on('rowselect',  function (selModel, rowIndex, record) {}
                );
        Ext.apply(this, {items:[grid]});
        this.callParent(arguments);
    }
});